package day08.edu;

import org.junit.Test;

import java.util.InputMismatchException;
import java.util.Scanner;

// Created: 09/08/2025, ChangJiang Ru
public class ExceptionHandleTest {
    @Test
    public void test1() {
        try {

            Scanner scan = new Scanner(System.in);
            int score = scan.nextInt();
            System.out.println(score);
        } catch (InputMismatchException e) {
            System.out.println("Catch the Input Mismatch Exception");
        } catch (NullPointerException e) {
            System.out.println("Catch the Null Pointer Exception");
        } catch (RuntimeException e) {
            System.out.println("Catch the Runtime Exception");
        }
        System.out.println("The exception have done");
    }

    @Test
    public void test2() {
        try {
            String str = "123";
            str = "abc";
            int intScore = Integer.parseInt(str);
            System.out.println(intScore);
        } catch (NumberFormatException e) {
            System.out.println("Catch the Number Format Exception");
            System.out.println(e.getMessage());
        }
        System.out.println("Programmer is over");
    }
}
